Repository navigation
Restore crypto.Signer for classical foreign JWS (fix #34) - #36
Conversation
Accept opaque HSM/KMS Signers for RSA/ECDSA/Ed25519 on NewJWSSigner and NewJWSVerifierWithAlg again; document v0.6.2 and credit the reporter. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@ilya-korotya thanks again for #34 / #35. Formal review request isn’t available (not a repo collaborator), but please check out this PR and run it against your HSM/KMS-backed |
|
Thanks for the fix, the classical algorithms work for me now! My main goal though was ML-DSA with the private key stored in AWS KMS, and that still fails, because ML-DSA only accepts a raw This is what I register: func init() {
for _, alg := range []jwa.SignatureAlgorithm{jwa.MLDSA44(), jwa.MLDSA65(), jwa.MLDSA87()} {
if err := jws.RegisterSigner(alg, mldsaCryptoSigner{}); err != nil {
panic(fmt.Sprintf("register ML-DSA signer for %s: %v", alg, err))
}
}
}
// mldsaCryptoSigner signs through crypto.Signer (e.g. a KMS-backed key)
// instead of requiring a raw *mldsa.PrivateKey.
type mldsaCryptoSigner struct{}
func (mldsaCryptoSigner) Sign(key any, payload []byte) ([]byte, error) {
signer, ok := key.(crypto.Signer)
if !ok {
return nil, fmt.Errorf("unsupported key type %T, want crypto.Signer", key)
}
if _, ok := signer.Public().(*mldsa.PublicKey); !ok {
return nil, fmt.Errorf("key's Public() is %T, want *mldsa.PublicKey", signer.Public())
}
// ML-DSA signs the message itself, no pre-hashing.
return signer.Sign(nil, payload, &mldsa.Options{})
}With this in place, the only thing that still blocks me is So could the ML-DSA part of #35 be kept in #36? Or, alternatively, would you consider adding a native ML-DSA signer that takes a crypto.Signer directly and doesn't go through jwx at all? |
Construction validates Public() and parameter set; Sign still needs stock *mldsa.PrivateKey or a custom jws.RegisterSigner (document + test). Co-authored-by: Cursor <cursoragent@cursor.com>
|
@ilya-korotya thanks for the classical confirmation and the ML-DSA / We extended this PR so opaque Could you please re-run against your AWS KMS ML-DSA signer on this branch and confirm end-to-end? (We deliberately did not add a native ML-DSA signer — ML-DSA stays foreign-JWS only.) |
|
Hi @yaronf, these changes worked for me. Thank you very much for your help. |
Summary
crypto.Signer(HSM/KMS) for classical foreign JWS RSA/ECDSA/Ed25519 onNewJWSSignerandNewJWSVerifierWithAlg(issue NewJWSSigner (v0.6.0+) rejects crypto.Signer wrappers that worked with NewJWSSignerV3 (v0.5.x)- breaks HSM/KMS-backed signing #34).Public()handling, tests).@ilya-korotya — please review and run this branch against your HSM/KMS-backed signer (the case that broke in v0.6.x). CI can’t exercise real remote keys; your run is the validation that matters.
Made with Cursor